package com.wan.core.timer.rule;

import java.time.LocalDateTime;

/**
 * @author wwh
 * @date 2022/6/28 15:51
 */
public enum WRules implements WRule {
    /** 仅执行一次 */
    ONCE{
        @Override
        public LocalDateTime nextTime(LocalDateTime executeTime, int period) {
            return null;
        }
    },
    /** 秒循环 */
    SECOND_REPEAT{
        @Override
        public LocalDateTime nextTime(LocalDateTime executeTime, int period) {
            return executeTime.plusSeconds(period);
        }
    },
    /** 分钟循环 */
    MINUTE_REPEAT{
        @Override
        public LocalDateTime nextTime(LocalDateTime executeTime, int period) {
            return executeTime.plusMinutes(period);
        }
    },
    /** 小时循环 */
    HOUR_REPEAT{
        @Override
        public LocalDateTime nextTime(LocalDateTime executeTime, int period) {
            return executeTime.plusHours(period);
        }
    },
    /** 天循环 */
    DAY_REPEAT{
        @Override
        public LocalDateTime nextTime(LocalDateTime executeTime, int period) {
            return executeTime.plusDays(period);
        }
    },
    /** 周循环 */
    WEEK_REPEAT{
        @Override
        public LocalDateTime nextTime(LocalDateTime executeTime, int period) {
            return executeTime.plusWeeks(period);
        }
    },
    /** 月循环 */
    MONTH_REPEAT{
        @Override
        public LocalDateTime nextTime(LocalDateTime executeTime, int period) {
            return executeTime.plusMonths(period);
        }
    },
    /** 年循环 */
    YEAR_REPEAT{
        @Override
        public LocalDateTime nextTime(LocalDateTime executeTime, int period) {
            return executeTime.plusYears(period);
        }
    }
    ;

}
